k=1.38*10^-23; %Boltzman constant
T=298; %temperature (25C)
E1=1.9; %dielectric constant of heptane
E2=1; %dielectric constant of air
E3=78.4; %dielectric constant of water
n1=1.39; %refractive index of heptane
n2=1; %refractive index of air
n3=1.33; %refractive index of water
h=6.63*10^-34; %Planck's constant
v=3*10^15; %main electronic absorption frequency
A1=(3*k*T*(E1-E3)*(E2-E3))/(4*(E1+E3)*(E2+E3));
A2=3*h*v*(n1^2-n3^2)*(n2^2-n3^2)/(8*2^0.5);
A3=(n1^2+n3^2)^0.5*+(n2^2+n3^2)^0.5*((n1^2+n3^2)^0.5+(n2^2+n3^2)^0.5);
AAirHep=A1+(A2/A3) %hamaker constant

figure

%Van der Waals force between 1 um radius air bubble and hepatane droplet
R1=1.4*10^-6; %Radius of air bubble
R2=25*10^-6; %Radius of curvature of heptane droplet
D=[1*10^-9:0.5*10^-9:350*10^-9];
F=-(AAirHep*R1*R2)./((6*D.^2)*(R1+R2));
plot(D*10^9,F*10^9,'r')
xlabel('Separation (nm)')
ylabel('Force (nN)')

% figure

% %Hydrodynamic drainage force between approaching probe and a solid surface in water
% n=10^-3; %viscosity of water
% R=8*10^-6; %radius of air bubble
% u=10^-6; %speed of the moving probe (1 um/s)
% h=[1*10^-9:0.5*10^-9:100*10^-9];
% F=6*pi*n*R*u*(1+(R./h));
% plot(h*10^9,F*10^9,'r')
% xlabel('Separation (nm)')
% ylabel('Hydrodynamic Drainage Force (nN)')

hold on
xcorr2=(xcorr1-3.0546)*10^3;
ycorr2=ycorr1;
plot(xcorr2,ycorr2,'b')
hold on
%plot exponential fit for the repulsive force observed
a1=1.322;
b1=-0.03383; %b1=-1/Decay length
x1=[0:0.1:350];
y1=a1*exp(b1.*x1);
plot(x1,y1,'k')

hold on

%plot exponential curve for the electrostatic double layer force
a2=1.322;
b2=-1/242; %b1=-1/Debye length
x2=[0:0.1:350];
y2=a2*exp(b2.*x2);
plot(x2,y2,'m')

legend('vdW forces','Experimental','Exponential fit','EDL forces')